package com.sleep.psy.external_server.utils;

/**
 * Created on 17/6/7.
 * 短信API产品的DEMO程序,工程中包含了一个SmsDemo类，直接通过
 * 执行main函数即可体验短信产品API功能(只需要将AK替换成开通了云通信-短信产品功能的AK即可)
 * 工程依赖了2个jar包(存放在工程的libs目录下)
 * 1:aliyun-java-sdk-core.jar
 * 2:aliyun-java-sdk-dysmsapi.jar
 *
 * 备注:Demo工程编码采用UTF-8
 * 国际短信发送请勿参照此DEMO
 */
public class GenCodeUtils {

	public static String getInviteCode() {
		String code = "";
		for (int j = 0; j < 9; j++) {
			double rand = Math.random();
			double randTri = Math.random() * 3;
			if (randTri >= 0 && randTri < 1) {
				code+=(char) (rand * ('9' - '0') + '0');
			} else if (randTri >= 1 && randTri < 2) {
				code+=(char) (rand * ('Z' - 'A') + 'A');
			} else {
				code+=(char) (rand * ('z' - 'a') + 'a');
			}
		}
		return code;
	}
	
	public static String getRedeemCode() {
		String code = "";
		for (int j = 0; j < 11; j++) {
			double rand = Math.random();
			double randTri = Math.random() * 3;
			if (randTri >= 0 && randTri < 1) {
				code+=(char) (rand * ('9' - '0') + '0');
			} else if (randTri >= 1 && randTri < 2) {
				code+=(char) (rand * ('Z' - 'A') + 'A');
			} else {
				code+=(char) (rand * ('z' - 'a') + 'a');
			}
		}
		return code;
	}
	
	
	 public static void main(String[] args) {
		   // MyMD5Util.encryption(userPwd + userCode).toUpperCase()
//		   for(int i=0;i<352;i++) {
			   System.out.println(GenCodeUtils.getInviteCode()); 
//		   }
		   
	}
   
}
